"use strict";
cc._RF.push(module, '472fdcFAQdHKJ5a2gSOJRK9', 'SettingViewUI');
// scripts/SettingViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("NotifyEventType"),
    n = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("ModuleUI"),
    l = e("CommonHelper"),
    _ = e("sdkConfig"),
    c = e("AD"),
    d = cc._decorator,
    h = d.ccclass,
    u = d.property,
    p = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.music_node = null, t.sound_node = null, t.shock_node = null, t.privacy_btn = null, t.give_up_btn = null, t.give_up_time = null, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    e.prototype.initView.call(this), c["default"].getInstance().getGameTestVersion() && c["default"].getInstance().showInter(), this.privacy_btn.active = _["default"].platform != _.EPlatform.TikTok && _["default"].platform != _.EPlatform.NO_AD && _["default"].platform != _.EPlatform.NET_4399 && !n.GlobalParams.PlayerJoinFight, this.give_up_btn.active = n.GlobalParams.PlayerJoinFight, this.shock_node.active = _["default"].platform != _.EPlatform.NET_4399, this.showSettingInfo(), this.give_up_btn.active && this.showGiveTime();
  }, t.prototype.OnClick = function (t) {
    switch (e.prototype.OnClick.call(this, t), t.node.name) {
      case "music_btn":
        n.GlobalParams.gameMusic.value = !n.GlobalParams.gameMusic.value, n.GlobalParams.gameMusic.value ? r["default"].playGameBGM() : r["default"].stopMusic(), this.showSettingInfo();
        break;

      case "sound_btn":
        n.GlobalParams.gameSound.value = !n.GlobalParams.gameSound.value, this.showSettingInfo();
        break;

      case "shake_btn":
        n.GlobalParams.gameShock.value = !n.GlobalParams.gameShock.value, n.GlobalParams.gameShock.value && c["default"].getInstance().vibrateShort(), this.showSettingInfo();
        break;

      case "back_btn":
        this.emitEvent(a["default"].SEND_BOX_PORTAL_INFO, !0), n.GlobalParams.PlayerJoinFight && _["default"].platform == _.EPlatform.TikTok && c["default"].getInstance().ResumeRecorder(), this.closeThisPopup();
        break;

      case "privacy_btn":
        this.uiManager.showPopup("privacy_view_ui");
        break;

      case "give_up_btn":
        cc.find("Canvas").addChild(cc.instantiate(i["default"].getInstance().getFightPrefab("give_up_view"))), this.closeThisPopup();
    }
  }, t.prototype.showSettingInfo = function () {
    this.music_node.children[0].active = !n.GlobalParams.gameMusic.value, this.sound_node.children[0].active = !n.GlobalParams.gameSound.value, this.shock_node.children[0].active = !n.GlobalParams.gameShock.value, this.music_node.children[1].active = n.GlobalParams.gameMusic.value, this.sound_node.children[1].active = n.GlobalParams.gameSound.value, this.shock_node.children[1].active = n.GlobalParams.gameShock.value;
  }, t.prototype.showGiveTime = function () {
    var e = this,
        t = n.GlobalParams.GameGiveUpTime - new Date().getTime();
    t <= 0 ? (this.give_up_time.node.active = !1, this.give_up_btn.getComponent(cc.Button).interactable = !0) : (this.give_up_time.string = l["default"].getTimeStrByNum(t, !1, 2), this.give_up_time.node.active = !0, this.give_up_btn.getComponent(cc.Button).interactable = !1, this.scheduleOnce(function () {
      e.showGiveTime();
    }, 1));
  }, oo([u(cc.Node)], t.prototype, "music_node", void 0), oo([u(cc.Node)], t.prototype, "sound_node", void 0), oo([u(cc.Node)], t.prototype, "shock_node", void 0), oo([u(cc.Node)], t.prototype, "privacy_btn", void 0), oo([u(cc.Node)], t.prototype, "give_up_btn", void 0), oo([u(cc.Label)], t.prototype, "give_up_time", void 0), oo([h], t);
}(s["default"]);

o["default"] = p;

cc._RF.pop();